package com.xique.park.controller.web;

import com.xique.common.core.domain.R;
import com.xique.common.core.utils.SecurityUtils;
import com.xique.common.core.web.domain.PageResult;
import com.xique.common.security.annotation.PreAuthorize;
import com.xique.park.bean.domain.ParkPlatemodifyRecord;
import com.xique.park.service.service.IParkPlatemodifyRecordServce;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 车牌修改记录
 *
 * @author xique
 */
@RestController
@RequestMapping("/web/parkPlatemodifyRecord")
public class WebParkPlatemodifyRecordController {

    @Autowired
    private IParkPlatemodifyRecordServce parkPlatemodifyRecordServce;

    @PostMapping("/addParkPlatemodifyRecord")
    public R<?> addParkPlatemodifyRecord(ParkPlatemodifyRecord parkPlatemodifyRecord) {
        boolean boo = parkPlatemodifyRecordServce.save(parkPlatemodifyRecord);
        if (!boo) {
            return R.fail("车牌修改记录添加错误");
        }
        return R.ok();
    }

    @PreAuthorize(hasPermi = "parking:list:license")
    @GetMapping("/getParkPlatemodifyRecordList")
    public R<PageResult> getParkPlatemodifyRecordList(Long laneId, String startTime, String endTime, String modifiedPlate, Integer pageNum, Integer pageSize) {
        Long parkId = SecurityUtils.getParkId();
        PageResult result;
        pageNum = pageNum != null ? pageNum : 1;
        pageSize = pageSize != null ? pageSize : 10;
        if (parkId != null) {
            result = parkPlatemodifyRecordServce.getParkPlatemodifyRecordList(parkId, laneId, startTime, endTime, modifiedPlate, pageNum, pageSize);
        } else {
            return R.fail("接口传入的parkIds为空");
        }
        return R.ok(result);
    }

}
